/**
 * Created by Yu Jin Xian on 2016/11/24.
 */
var http = require('http');

http.createServer(pathing).listen(3000);

console.log('Server started on localhost:3000l press Ctrl+C to terminate....');

function pathing(req, res) {
    var path = req.url.replace(/\/?(?:\?.*)?$/, '').toLowerCase();
    switch (path) {
        case '':
            res.writeHead(200, {'Content-Type': 'text/plain'});
            res.end('Homepage');
            break;
        case '/about':
            res.writeHead(200, {'Content-Type': 'text/plain'});
            res.end('About');
            break;
        default :
            res.writeHead(404, {'Content-Type': 'text/plain'});
            res.end('Not Found');
            break;
    }
}